package com.zx.system.block.param;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.StatusUpdate;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: 角色请求参数 <br>
 * create: 2024-10-29 14:43
 * </p>
 *
 * @author zhou  xun
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class RoleParam implements Serializable, Create, Update, StatusUpdate {
    /**
     * 角色ID
     */
    @ParameterValidation(index = 0, desc = "角色ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~32")
    private String id;

    /**
     * 角色名称
     */
    @ParameterValidation(index = 0, desc = "角色名称", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~30")
    private String name;

    /**
     * 角色权限字符串
     */
    @ParameterValidation(index = 0, desc = "权限字符串", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~100")
    private String roleKey;

    /**
     * 显示顺序
     */
    @ParameterValidation(index = 0, desc = "显示顺序", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.NON_NEGATIVE_NUMBER})
    private Integer seqNo;

    /**
     * 角色状态（0停用 1启用)
     */
    @ParameterValidation(index = 0, desc = "角色状态", rules = {ValidateRulesEnum.NOT_NULL})
    private Integer status;

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 备注
     */
    @ParameterValidation(index = 0, desc = "备注", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String remark;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("name", "roleKey", "seqNo", "status", "remark");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id", "name", "roleKey", "seqNo", "status", "remark");
    }

    @Override
    public Set<String> getStatusUpdateGroupFields() {
        return Set.of("id", "status");
    }
}